var num = 1;


$(function(){
    newsListInit(num);
    // window.onscroll = function(ev) {
    // if ((window.innerHeight + window.scrollY) >= document.body.offsetHeight) {
    //     console.log('到底了')
    //     num++
    //     newsListInit(num);
    // }};
})

function moreMess(){
    $('.more button').attr('disabled',true)
    num++
    newsListInit(num);
}

function newsListInit(num){
    $.ajax({
        url: "/spider/get/financialNews",
        async: true,
        data: {
            pageIndex:num,
            pageSize:20,
            sortName:'',
            sortOrder:'desc'
        },
        type: "POST",
        dataType: "json",
        success: function (result) {
            if(result.code == "000000"){
                // console.log(result.data)
                var html = '';
                $.each(result.data,function(index,item){
                    html += `<li style="display: flex;background-color:#f4f4f7">
                        <div class="newTime">
                            <p class="time">${item.newsTime}</p>
                            <p>${item.newsDate}</p>
                        </div>
                        <div class="newMess">
                            <p style="text-indent: 20px;line-height: 30px">${item.newsContent}</p>
                            <p style="text-align: right">关键字：<span style="color: #4460f1">${item.newsKey}</span></p>
                        </div>
                        </li>`
                })
                $('.newList').append(html);
                $('.more button').attr('disabled',false)
            }
        },
        error: function (res){
            alert('请求失败')
        }
    })
}